# -*- coding: utf-8 -*-
# pip install qiniu glob2
from qiniu import Auth, put_file
import qiniu.config
import glob2
import os
#需要填写你的 Access Key 和 Secret Key
access_key = 'UX_NQBSUlHs_6JaFogW5jjO6yYI2lYsDpZ4mXXi1'
secret_key = '3d0-XChjvWZKmFhdnjDSOU2XvykkaULK8TW9MGpP'
#构建鉴权对象
q = Auth(access_key, secret_key)
#要上传的空间
bucket_name = 'suning'

resources = glob2.glob('dist/static/**')
def upload(path):
  file_name = path.replace('dist/', '')
  key = file_name.replace('\\', '/')
  token = q.upload_token(bucket_name, key, 3600)
  localfile = './' + path
  ret, info = put_file(token, key, localfile)
  print(info, ret)

for r in resources:
  if os.path.isfile(r):
   upload(r)
